<template>
	<view>
	<cu-custom :isBack="true">
		<block slot="backText"></block>
		<block slot="content">{{corpCode}}-复核</block>
	</cu-custom>
	<view class="content">
		<view class="cu-bar bg-white search fixed" :style="[{top:CustomBar + 'px'}]">
			<view class="search-form round">
				<text class="cuIcon-search"></text>
				<input @confirm="sub" v-model="soDjno" type="text" placeholder="输入搜索的关键词" :focus="focus"></input>
			</view>
			<view class="action">
				<text  @click="toScan" class="cuIcon-scan" style="font-size: 56rpx;"></text>
				<text  @click="toImage" class="cuIcon-camera" style="font-size: 56rpx;"></text>
				<!-- <text class="cuIcon-camera" style="font-size: 56rpx;"></text> -->
			</view>
		</view>
		<view style="height: 60px;">
			
		</view>
		<view class="" style="padding: 10px;font-size: 20px">
			参考号：{{soCode}}
		</view>
		<uni-table border stripe emptyText="暂无更多数据" type="selection1">
			<uni-tr>
				<uni-th align="center">SKU</uni-th>
				<uni-th align="center">序列号</uni-th>
			</uni-tr>
			<uni-tr v-for="(item, index) in list " :key="index">
				<uni-td align="center">{{item.barCode}}</uni-td>
				<uni-td align="center">{{item.basInv.cinvname || ''}}</uni-td>
			</uni-tr> 
		</uni-table>
	</view>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex';
	import uniTable from 'components/uni-table/uni-table.vue';
	import uniTh from 'components/uni-th/uni-th.vue';
	import uniTr from 'components/uni-tr/uni-tr.vue';
	import uniTd from 'components/uni-td/uni-td.vue';
	export default {
		name:'wechat',
		props: {
			scrollHeight:{ 
				type:String,
				default:"600px"
			}
		},
		data() {
			return {
				focus:true,
				soCode:'',
				list:[],
				soDjno:'',
				CustomBar: this.CustomBar, //滚动定位用
			   filterText: '',
			   modalName:'',
			   flName:'请选择分类',
			   mscode:'',
			   data: [{mcode:'',mname:'',childs:[]}],
			   page:{
					total: 0,  //共多少条
					pageSize: 50,//每页条数
					currentPage: 1 //第几页
				  },
				scrollTop: 0,
				delayload: false,
				Seltim: [],
				initStartDate: '',
				initEndDate: '',
				orgname:'',
				name:'',
				companyList:[],
				flList:[],
				rDate:'',
				lDate:'',
				companyName:'',
				pageSize:50,
				pageNo:1,
				defaultProps: {
					children: 'childs',
					label: 'mname',
				},
				invPosData: [],
				cinvcodes:'',
				cinvnames:'',
				cposnames:'',
				
			}
		},
		onShow() {
			
		},
		onLoad(data) {
			this.soCode = data.soCode
		},
		computed: {
			...mapState(['hasLogin', 'userInfo', 'auditlist', 'corpCode']),
		},
		methods:{
			/** 扫发出声音*/
			makeSound(name){
				console.log("=====testClick=====");
				let src = '../../static/'+name+'.mp3';
				//实例化声音  
				const Audio = uni.createInnerAudioContext();
				Audio.autoplay = true;
				Audio.src = src; //音频地址  
				Audio.play(); //执行播放  
				Audio.onError((res) => {
				});
				Audio.onPause(function() {
					console.log('end');
					Audio.destroy();
				});
			},
			toImage(){
				uni.navigateTo({
					url: '/pages/dbfh/upload?soCode=' + this.soCode,
				})
			},
			sub(){
				if(!this.soDjno){
					this.$api.msg('请扫描正确的单号!');
					return;
				}
				this.focus = false
				uni.request({
					url:this.serverURL_a+'/so/App/checkOrderPickCN',
					data:{
						soCode : this.soCode,
						snnumber : this.soDjno,
						__sid:this.userInfo.sessionid
					},
					header: {
						'content-type': 'application/x-www-form-urlencoded;charset=utf-8',
					},
					method: 'POST',
					success:function(data){
						this.soDjnoPos = this.soDjno;
						this.soDjno = '';
						var requrt = data.data;
						setTimeout(()=>{
							this.focus = true
						},500)
						if(requrt.result == 'true'){
							this.makeSound("cg");
							this.list.push(requrt.data)
						}else{
							// this.$api.msg(requrt.msg);
							this.makeSound("sb");
							uni.showModal({
							    content: requrt.message,
								showCancel:false,
							});
							return;
						}
					}.bind(this),
					fail:function(){
						this.$api.msg('服务已停止,请稍后再试');
						return;
					}.bind(this),
				});
				
			},
			toScan() {
				uni.scanCode({
					onlyFromCamera: true,
					success: function(res) {
						this.soDjno = res.result;
						this.soDjnoPos=res.result;
						this.sub();
					}.bind(this)
				});
			},
			getPosData(){
				if(this.pageNo==1){
					this.list=[];
				};
				let soDjno=this.soDjno;
				//let cinvname=this.cinvnames;
				let cinvcode=this.cinvcodes;
				let cposname=this.cposnames;
				let pageSize=this.pageSize;
				let pageNo=this.pageNo;
				uni.request({
					url:this.serverURL_a+'/wh/u8/u8InvpositionSum/findInvPosNum?__ajax=json',
					data:{
						soDjno : soDjno,
						cinvcode : cinvcode,
						cposname : cposname ,
						pageSize:pageSize,
						pageNo:pageNo,
						__sid:this.userInfo.sessionid,
					},
					header: {
						'content-type': 'application/x-www-form-urlencoded;charset=utf-8',
					},
					method: 'POST',
					success:function(data){
						let ret = data.data;
						//获取总条数，其余显示插件自动计算
						this.page.total = ret.count;
						if(data.statusCode!="200"){
							uni.showModal({
								content: ret.message,
								showCancel:false,
							});
							return;
						}
						this.invPosData = ret.list;
					}.bind(this),
					fail:function(){
						this.$api.msg('服务已停止,请稍后再试');
						return;
					}.bind(this),
				});
			},
			showModal(e) {
				this.modalName = e.currentTarget.dataset.target
			},
			hideModal(e) {
				this.modalName = null
			},
			change(currentPage, type){
			      this.page.currentPage = currentPage;
				  this.pageNo= this.page.currentPage;
				  this.getPosData();
			},
		}
	}
</script>

<style scoped lang="less">
	.cu-dialog{
		    height: 300px;
		    overflow: auto;
	}
	.content{
		padding-top: 10rpx;
		.progress,.firend_operate{
			padding: 0 10rpx;
		}
		.progress{
			margin-bottom: 20rpx;
		}
		.friend_operate{
			padding: 30rpx 20rpx;
			.title{
				text-align:left;
				margin-bottom: 30rpx;
				font-size: 40rpx;
			}
			.trend_title{
				text-align: right;
				font-size: 22rpx;
				color: #ff9900;
				margin-top: 50rpx;
			}
		}
	}
	
	.ly-search {
		margin: 0 30rpx;
		margin-top: 40rpx;
		padding-bottom: 15rpx;
		border-bottom: 1px solid #ededed;
	}
	.container {
		padding: 20rpx 0 50rpx 0;
	}
	
	.tui-line-cell {
		width: 100%;
		box-sizing: border-box;
		display: flex;
		align-items: center;
	}
	
	.tui-title {
		line-height: 32rpx;
		min-width: 120rpx;
		flex-shrink: 0;
	}
	
	.tui-input {
		font-size: 32rpx;
		color: #333;
		padding-left: 20rpx;
		flex: 1;
		overflow: visible;
	}
	
	.radio-group {
		margin-left: auto;
		transform: scale(0.8);
		transform-origin: 100% center;
		flex-shrink: 0;
	}
	
	.tui-radio {
		display: inline-block;
		padding-left: 28rpx;
		font-size: 36rpx;
		vertical-align: middle;
	}
	
	
	.tui-btn-box {
		padding: 40rpx 50rpx;
		box-sizing: border-box;
	}
	
	.tui-button-gray {
		margin-top: 30rpx;
	}
	
	.tui-tips {
		padding: 30rpx;
		color: #999;
		font-size: 24rpx;
	}
	
	.d-container {
		width: 400rpx;
		padding: 80rpx 30rpx;
	}
	
	.usingtext{
		margin-left: 30rpx;
		color: #999;
	}
	
	.tui-right {
		margin-left: auto;
		padding-right: 30rpx;
		color: #999;
	}
	
	.numtext{
		text-align: center;
	}
</style>

